package ngames.com.sushitv.Fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;

import ngames.com.sushitv.R;
import ngames.com.sushitv.temp.Adapter.MyPagerAdapter;
import ngames.com.sushitv.view.Indicator;

/**
 * Created by edmond on 16-7-26.
 */
public class ActivityFragment extends Fragment{
    private View view;

    private ArrayList<Fragment> fragments;
    private MyPagerAdapter adapter;
    private Indicator indicator;
    private ViewPager viewPager;

    private MessagesFragment messagesFragment;
    private RepliesFragment repliesFragment;
    private MentionsFragment mentionsFragment;
    private NotificationsFragment notificationsFragment;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        view = inflater.inflate(R.layout.fragment_activity,container,false);

        init();

        return view;
    }

    private void init(){
        indicator = (Indicator) view.findViewById(R.id.indicator);
        viewPager = (ViewPager) view.findViewById(R.id.viewPager);

        fragments = new ArrayList<>();
        messagesFragment = new MessagesFragment();
        mentionsFragment = new MentionsFragment();
        repliesFragment = new RepliesFragment();
        notificationsFragment = new NotificationsFragment();
        fragments.add(messagesFragment);
        fragments.add(repliesFragment);
        fragments.add(mentionsFragment);
        fragments.add(notificationsFragment);

        adapter = new MyPagerAdapter(getChildFragmentManager(),fragments);
        viewPager.setAdapter(adapter);
        indicator.setViewPager(viewPager,0);

        Log.d("activity","init");
    }
}
